// © 2009 Microsoft Corporation.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

[assembly: System.Web.UI.WebResource("Microsoft.InformationSecurity.CISF.Web.AjaxExtenders.UTCToLocalExtenderBehavior.js", "text/javascript")]
namespace Microsoft.InformationSecurity.CISF.Web.AjaxExtenders
{
    /// <summary>
    /// Summary description for ExtenderControl1
    /// </summary>
    [TargetControlType(typeof(Control))]
    public class UTCToLocalExtenderControl : ExtenderControl
    {
        public UTCToLocalExtenderControl()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        protected override IEnumerable<ScriptDescriptor>
                GetScriptDescriptors(System.Web.UI.Control targetControl)
        {
            ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("Microsoft.InformationSecurity.CISF.Web.AjaxExtenders.UTCToLocalExtenderBehavior", targetControl.ClientID);
            descriptor.AddProperty("DateTimeFormatString", this.DateTimeFormatString);
            yield return descriptor;
        }

        // Generate the script reference
        protected override IEnumerable<ScriptReference>
                GetScriptReferences()
        {
            yield return new ScriptReference("Microsoft.InformationSecurity.CISF.Web.AjaxExtenders.UTCToLocalExtenderBehavior.js", this.GetType().Assembly.FullName);
        }

        public string DateTimeFormatString
        {
            get { return (string)(ViewState["DateTimeFormatString"] ?? "g"); }
            set { ViewState["DateTimeFormatString"] = value; }
        }

    }
}